//
//  ViewController.m
//  网易新闻头部V2
//
//  Created by qianfeng on 15/9/23.
//  Copyright (c) 2015年 孔令涛. All rights reserved.
//

#import "ViewController.h"
#import "KLTTopBar.h"
#import "TopBarView.h"
#import "AFNetworking.h"
#import "ZJModelTool.h"
#import "TopBarModel.h"
#import "HomePage.h"

#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define ScreenHeight [UIScreen mainScreen].bounds.size.height
#define StatusBarHeight 20
#define NavigationHeight 44
#define TabBarHeight 49
#define ToolBarHeight 44
@interface ViewController ()

{
    KLTTopBar * _tct;
    NSMutableArray * _viewArray;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // 如果不关,那么就会在(0 ,20)处
    self.automaticallyAdjustsScrollViewInsets = NO;
    _viewArray = [[NSMutableArray alloc]init];
    [self creatUI];
    
}
- (void)creatUI
{
    NSArray * urlArray =@[@"http://qt.qq.com/static/pages/news/phone/c12_list_1.shtml",@"http://qt.qq.com/static/pages/news/phone/c23_list_1.shtml",
                          @"http://qt.qq.com/static/pages/news/phone/c73_list_1.shtml",
                          @"http://qt.qq.com/static/pages/news/phone/c18_list_1.shtml",
                          @"http://qt.qq.com/static/pages/news/phone/c3_list_1.shtml",
                          @"http://qt.qq.com/static/pages/news/phone/c17_list_1.shtml",
                          @"http://qt.qq.com/static/pages/news/phone/c10_list_1.shtml"];
    
    NSArray * titleArray = @[@"最新",@"活动",@"赛事",@"娱乐",@"官方",@"美女",@"攻略"];
    for (int i = 0; i < titleArray.count ; i++) {
        if (i == 0) {
            HomePage * view = [HomePage HomePageWithIndex:i UrlString:urlArray[i]];
            view.tag = i;
            [_viewArray addObject:view];
        }
        else
        {
        TopBarView * view = [TopBarView topBarWithIndex:i UrlString:urlArray[i]];
        view.tag = i;
        [_viewArray addObject:view];
        }
    }
    
    
    _tct = [KLTTopBar TopBar];
    _tct.titleArray = titleArray;
    _tct.viewArray = _viewArray;
    _tct.currentView = _tct.viewArray[0];

    [self.view addSubview:_tct];
}


- (void)didReceiveMemoryWarning {
    
    [super didReceiveMemoryWarning];
    
    //发出内存警告的时候    调用清理内存的方法
    [_tct cleanMemory];
    
}
@end
